package com.yangweiye.communicationonline;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author Lete
 * @乐特的程序永无BUG
 * @createDate 2020- 07-04 22:13
 *
 * 1. SendThread 发送消息线程
 * 2. RecieveThread 接受消息线程
 */
public class SendThread extends Thread {

    private Socket s;

    public SendThread(Socket s) {
        this.s = s;
    }

    public void run() {
        try {

            // 获取输入的内容
            OutputStream os = s.getOutputStream();
            DataOutputStream dos = new DataOutputStream(os);

            while (true) {
                Scanner sc = new Scanner(System.in);
                String str = sc.next();
                dos.writeUTF(str);
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

}
